<html>
<head>
<script>
  function setTitle() {
  document.title = 'foo';
}
</script>
</head>
<body onload="setTitle();">
<div id='bar'>a div</div>
</body>
</html>
